package com.pedromassango.delyo.ui.gives

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.pedromassango.delyo.R

class GiveAdapter (val give:ArrayList<Gives>): RecyclerView.Adapter<GiveAdapter.GiveviewHolder>()
{
    inner class GiveviewHolder(itemView: View): RecyclerView.ViewHolder(itemView)
    {
        val givename =itemView.findViewById<TextView>(R.id.givetitle)
        val givedescription=itemView.findViewById<TextView>(R.id.givedesc)
        val givepicture=itemView.findViewById<ImageView>(R.id.giveimage)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): GiveviewHolder {
        val view= LayoutInflater.from(parent.context).inflate(R.layout.activity_give,parent,false)
        val holder=GiveviewHolder(view)
        return holder
    }

    override fun onBindViewHolder(holder: GiveviewHolder, position: Int) {
        val give=give[position]
        holder.givename.text=give.givename
        holder.givedescription.text=give.givedescription
        holder.givepicture.setImageResource(give.givepicture)
    }

    override fun getItemCount(): Int {
        return give.size
    }
}
